package com.bw.ivideo.ui

import android.content.Intent
import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.CountDownTimer
import android.view.LayoutInflater
import androidx.databinding.DataBindingUtil
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.ivideo.BuildConfig
import com.bw.ivideo.R
import com.bw.ivideo.common.ConstanstValue
import com.bw.ivideo.databinding.ActivitySplashBinding
import com.jaeger.library.StatusBarUtil

class SplashActivity : AppCompatActivity() {

    var binding: ActivitySplashBinding? = null
    lateinit var countDownTimer: CountDownTimer

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this, R.layout.activity_splash)
        setContentView(binding?.root)
        StatusBarUtil.setColorNoTranslucent(this, Color.WHITE)
    }

    override fun onResume() {
        super.onResume()

        binding?.tvSplashTime?.text = String.format("当前版本:%s", BuildConfig.VERSION_NAME)

        countDownTimer = object : CountDownTimer(5000, 1000){
            override fun onTick(millisUntilFinished: Long) {
                binding?.tvSplashTime?.text = String.format("倒计时%sS", millisUntilFinished/1000)
            }

            override fun onFinish() {
                ARouter.getInstance().build(ConstanstValue.APP_HOMEACTIVITY_PATH).navigation()
                finish()
            }

        }.start()

    }

}